
	
	clear all
	set more off 
	version 14.2	
	
	* install randomization inference package if not already installed. This package is available from Stata version 14
	* ssc install ritest 
	* ssc install estout 
	* ssc install outreg 
	
******************************************************	
	* call in a `Politician Survey' dataset
	use "Kim_Michelitch_Politician.dta", clear 	


******************************************************	
** Main paper
******************************************************	

******************************************************	
** Create a dataset for the main analysis

	drop if noteligible != . /** drop respondents who were not eligible (died, resigned, refused survey, subcounty eliminated, councilor changed)**/ 
	drop if software_prob == 1 /** drop respondents where technical glitch led to missing values in dv**/ 
	drop if mandate == 1 & female == 1 /** drop female councilors in regular seats. To replicate results with female councilors in regular seats, skip this line of code**/ 

	saveold "Kim_Michelitch_Politician (main).dta", replace 	

	
******************************************************	
** Table 1
	
	* run regression (Model 1) 
	reg s_minus_h same_gender_sc 
	
	* export regression table 
	outreg2 using "regression.tex", replace ctitle(Model 1) keep (same_gender_sc)
	
	* run regression (Model 2) 
	regress s_minus_h same_gender_sc##female
		
	* export regression table 
	outreg2 using "regression.tex", append ctitle(Model 2) keep (same_gender_sc same_gender_sc##female) 


******************************************************	
******************************************************	
** Supplementary Information 
******************************************************	
******************************************************	

******************************************************	
** Table 1

	* call in a dataset with original target sample
	use "Kim_Michelitch_Politician.dta", clear 
	
	
	* results from the following command are manually entered into the table 
	numlabel `r(names)', add

	preserve 
	
	tab noteligible district /** columns for died, resigned, refused survey, subcounty eliminated, councilor changed**/ 
	drop if noteligible != . /** remove explained observations**/ 
	
	tab software_prob district /**column for software malfunction**/ 
	drop if software_prob == 1 /**remove explained observations**/ 
	
	tab district if mandate == 1 & female == 1 /**column for female in open seat**/ 

	restore 
	
******************************************************	
** Table 2
	
	preserve
	
	drop if noteligible != . /** drop respondents who were not eligible**/ 
	drop if mandate == 1 & female == 1 /** drop female councilors in regular seats.**/ 
	
	* results from the following models are manually entered into the table 	
	ttest schoolvis, by (resp)
	ttest healthvis, by (resp)
	ttest priority_edu1, by (resp)
	ttest priority_edu2, by (resp)
	ttest female, by(resp) 
	ttest coun_age, by (resp)
	ttest coun_educ, by (resp)			
	ttest coun_terms, by (resp)			
	ttest ruling_party, by (resp)			

	restore 
	
	
******************************************************		
* Figure 2

	* call in the dataset for the main analysis
	use "Kim_Michelitch_Politician (main).dta", replace 
	
	* plot a violin graph (top-left)
	vioplot s_minus_h, scheme(s2mono) graphregion(fcolor(white))
	graph save "dv_violin", replace
	graph export "dv_violin.pdf", replace

	* plot a violin graph by gender (top-right)
	vioplot s_minus_h, over(female) scheme(s2mono) graphregion(fcolor(white))
	graph save "dv_violin_gender", replace 
	graph export "dv_violin_gender.pdf", replace 

	* plot a violin graph by treatemnt (bottom-left)
	vioplot s_minus_h, over(same_gender_sc) scheme(s2mono) graphregion(fcolor(white))
	graph save "dv_violin_samesc", replace 
	graph export "dv_violin_samesc.pdf", replace

	* plot a violin graph by gender and treatment (bottom-right)
	vioplot s_minus_h, over(same_gender_sc) over(female) scheme(s2mono) graphregion(fcolor(white))
	graph save "dv_violin_samesc_gender", replace 
	graph export "dv_violin_samesc_gender.pdf", replace	
	

	
******************************************************		
* Figure 3
	
	* plot a histogram (top-left)
	hist coun_age, by(same_gender_sc) scheme(s1mono) 
	graph save "age_hist", replace 
	graph export "age_hist.pdf", replace

	* plot a histogram (top-right)	
	hist coun_terms, discrete by(same_gender_sc) xlabel(0(1)3) scheme(s1mono) 
	graph save "coun_terms_hist", replace 
	graph export "coun_terms_hist.pdf", replace

	* plot a histogram (bottom-left)	
	hist coun_educ, discrete by(same_gender_sc) xlabel(1(1)12) scheme(s1mono) 
	graph save "educ_hist", replace 
	graph export "educ_hist.pdf", replace

	* plot a histogram (bottom-right)		
	hist ruling_party, discrete by(same_gender_sc) xlabel(0(1)1) scheme(s1mono) 
	graph save "ruling_party_hist", replace 
	graph export "ruling_party_hist.pdf", replace

******************************************************		
* Figure 4

	* plot a histogram (top-left)
	hist schoolvis, discrete by(same_gender_sc) xlabel(0(1)1) scheme(s1mono) 
	graph save "schoolvis_hist", replace 
	graph export "schoolvis_hist.pdf", replace

	* plot a histogram (top-right)		
	hist healthvis, discrete by(same_gender_sc) xlabel(0(1)1) scheme(s1mono) 
	graph save "healthvis_hist", replace 
	graph export "healthvis_hist.pdf", replace

	* plot a histogram (bottom-left)		
	hist priority_edu1, discrete by(same_gender_sc) xlabel(0(1)1) scheme(s1mono) 
	graph save "priority_edu1_hist", replace 
	graph export "priority_edu1_hist.pdf", replace

	* plot a histogram (bottom-right)		
	hist priority_edu2, discrete by(same_gender_sc) xlabel(0(1)1) scheme(s1mono) 
	graph save "priority_edu2_hist", replace 
	graph export "priority_edu2_hist.pdf", replace
	
		
******************************************************		
** Table 3 

	* results from the following tests (mean values, differences, and observations) are manually entered 
	ttest schoolvis, by (same_gender_sc)	
	ttest healthvis, by (same_gender_sc)		
	ttest priority_edu1, by (same_gender_sc)	
	ttest female, by (same_gender_sc) 
	ttest coun_age, by (same_gender_sc)
	ttest coun_educ, by (same_gender_sc)			
	ttest coun_terms, by (same_gender_sc)			
	ttest ruling_party, by (same_gender_sc)	
	
	* F-test results with `Personal Priority Edu 1' controlled (reported in text)
	reg same_gender_sc schoolvis healthvis priority_edu1 female coun_age coun_educ coun_terms ruling_party
	mvtest means schoolvis healthvis priority_edu1 female coun_age coun_educ coun_terms ruling_party, by(same_gender_sc)

	* F-test results with `Personal Priority Edu 2' controlled (reported in text)	
	reg same_gender_sc schoolvis healthvis priority_edu2 female coun_age coun_educ coun_terms ruling_party
	mvtest means schoolvis healthvis priority_edu2 female coun_age coun_educ coun_terms ruling_party, by(same_gender_sc)


******************************************************	
** Appendix F Robustness Checks - in text (p16) 
	
	** one-way ANOVA  
	oneway s_minus_h same_gender_sc, tabulate 
	
	** tukey post-hoc test 
	pwmean s_minus_h, over(same_gender_sc) mcompare(tukey) effects 
	
	** kruskal-wallis test 
	kwallis s_minus_h, by(same_gender_sc)
	
		
******************************************************	
* Table 4

	* Model 1 `Personal Priority Edu 1' var controlled 
	regress s_minus_h same_gender_sc##female schoolvis healthvis priority_edu1 coun_age coun_educ ruling_party coun_terms 
	outreg2 using "regression_ctrl.tex", replace ctitle(Model 1) keep (same_gender_sc##female schoolvis healthvis priority_edu1 coun_age coun_educ ruling_party coun_terms ) ///
	addtext (District FE, NO)

	* Model 2 `Personal Priority Edu 1' var controlled + district fixed effect 
	xtset district 
	xtreg s_minus_h same_gender_sc##female schoolvis healthvis priority_edu1 coun_age coun_educ ruling_party coun_terms, robust
	outreg2 using "regression_ctrl.tex", append ctitle(Model 2) keep (same_gender_sc##female schoolvis healthvis priority_edu1 coun_age coun_educ ruling_party coun_terms) ///
	addtext (District FE, YES)

	* Model 3 `Personal Priority Edu 2' var controlled	
	regress s_minus_h same_gender_sc##female schoolvis healthvis priority_edu2 coun_age coun_educ ruling_party coun_terms 
	outreg2 using "regression_ctrl.tex", append ctitle(Model 2) keep (same_gender_sc##female schoolvis healthvis  priority_edu2 coun_age coun_educ ruling_party coun_terms ) ///
	addtext (District FE, NO)

	* Model 4 `Personal Priority Edu 2' var controlled + district fixed effect 	
	xtset district 
	xtreg s_minus_h same_gender_sc##female schoolvis healthvis priority_edu2 coun_age coun_educ ruling_party coun_terms, robust
	outreg2 using "regression_ctrl.tex", append ctitle(Model 4) keep (same_gender_sc##female schoolvis healthvis priority_edu2 coun_age coun_educ ruling_party coun_terms) ///
	addtext (District FE, YES)
	

******************************************************	
** Table 5
	
	*results from the following models are manually entered into the table 	

	* keep only male politicians and run a t-test (results in the left column) 
	preserve 
		keep if female == 0
		ttest s_minus_h, by (same_gender_sc) 
	restore 

	* keep only female politicians and run a t-test (results in the right column) 
	preserve 
		keep if female == 1
		ttest s_minus_h, by (same_gender_sc) 
	restore 
	
	* keep only politicians listened to the recording of same gender and run a t-test (results in the first row)  
	preserve 
		keep if same_gender_sc == 1
		ttest s_minus_h, by (female) 
	restore 

	* keep only politicians listened to the recodring of opposite gender and run a t-test (results in the second row)
	preserve 
		keep if same_gender_sc == 0
		ttest s_minus_h, by (female) 
	restore 

	
	
******************************************************	
** Table 6

	* run a t-test 
	ttest s_minus_h_alt, by (same_gender_sc) 
	
	* create a table 
	estpost ttest s_minus_h_alt, by(same_gender_sc) 
	esttab using "ttest_alt_table.tex", label replace 	


******************************************************	
** Table 7
	
	*results from the following models are manually entered into the table 		

	* Model 1 
	ritest same_gender_sc _b[same_gender_sc], reps(1000) seed(123): regress s_minus_h same_gender_sc 

	* Model 2 
	ritest same_gender_sc _b[same_gender_sc], reps(5000) seed(456): regress s_minus_h same_gender_sc 
	

******************************************************	
** Table 8
			
	* Model 1 
	reg s_minus_h schoolvis 
	outreg2 using "regression_notreat.tex", replace ctitle(Model 1) keep (schoolvis) 	

	* Model 2	
	reg s_minus_h healthvis 
	outreg2 using "regression_notreat.tex", append ctitle(Model 2) keep (healthvis) 	

	* Model 3	
	reg s_minus_h priority_edu1 	
	outreg2 using "regression_notreat.tex", append ctitle(Model 3) keep (priority_edu1) 	

	* Model 4	
	reg s_minus_h priority_edu2 	
	outreg2 using "regression_notreat.tex", append ctitle(Model 4) keep (priority_edu2) 	

	* Model 6
	reg s_minus_h female 	
	outreg2 using "regression_notreat.tex", append ctitle(Model 5) keep (female) 	

	* Model 7		
	reg s_minus_h coun_age 	
	outreg2 using "regression_notreat.tex", append ctitle(Model 6) keep (coun_age) 		

	* Model 8	
	reg s_minus_h coun_educ 	
	outreg2 using "regression_notreat.tex", append ctitle(Model 7) keep (coun_educ)	

	* Model 9	
	reg s_minus_h ruling_party 	
	outreg2 using "regression_notreat.tex", append ctitle(Model 8) keep (ruling_party)

	* Model 10	
	reg s_minus_h coun_terms 	
	outreg2 using "regression_notreat.tex", append ctitle(Model 9) keep (coun_terms)				
		
		
******************************************************	
** Table 9 & 10 
	
	* call in a `Citizen Survey' dataset  
	use "Kim_Michelitch_Citizen.dta",clear
	
	* set global outcome for loop 
	global outcomes Infrastructure Water Health Education Poverty Agriculture Economy Violence Governance Gender Other 

	* run seemingly unrelated regression 	
	foreach y in $outcomes {
		xi: reg `y' female i.district_id
		est sto `y'
		} 
	suest $outcomes, cformat(%9.3f) 
	test female 
	
	*create regression tables 
	esttab Infrastructure Water Health Education Poverty using "female_polpri1.tex", star(* 0.10 ** 0.05 *** 0.01) se b(3) se(3) r2(2) label replace ///
		keep(female) stats(N,layout("\multicolumn{1}{c}{@}") labels("Observations") f(0)) ///
		title(Likelihood of Policy Domain Prioritization\label{tab:suest1})  ///
		nonotes ///
		addnote("Pooled seemingly unrelated regression analyses with district fixed effects." "Standard errors are in parentheses. $^* p<0.10$, $^{**} p<0.05$, $^{***} p<0.01$")
		
	esttab Agriculture Economy Violence Governance Gender Other using "female_polpri2.tex", star(* 0.10 ** 0.05 *** 0.01) se b(3) se(3) r2(2)   label replace ///
		keep(female) stats(N,layout("\multicolumn{1}{c}{@}") labels("Observations") f(0)) ///
		title(Likelihood of Policy Domain Prioritization\label{tab:suest2})  ///
		nonotes ///
		addnote("Pooled seemingly unrelated regression analyses with distrcit fixed effects." "Standard errors are in parentheses. $^* p<0.10$, $^{**} p<0.05$, $^{***} p<0.01$")

		
		
******************************************************	
** Figure 6

	*graph marginal effect (bottom panel in Figure 7) 
	preserve 
		parmest, level(90) label format(estimate min90 max90 p %8.3f ) norestore 
		keep if parm=="female"
		gen ids=_n
		gen outcome =1 if eq=="Infrastructure_mean"		
		replace outcome =2 if eq=="Water_mean"
		replace outcome =3 if eq=="Health_mean"
		replace outcome =4 if eq=="Education_mean"
		replace outcome =5 if eq=="Poverty_mean"
		replace outcome =6 if eq=="Agriculture_mean"
		replace outcome =7 if eq=="Economy_mean"
		replace outcome =8 if eq=="Violence_mean"
		replace outcome =9 if eq=="Governance_mean"
		replace outcome =10 if eq=="Gender_mean"
		replace outcome =11 if eq=="Other_mean"

		lab define outcomes 1 "Infrastructure" 2 "Water" 3 "Health" 4 "Education" 5 "Poverty" 6 "Agriculture" 7 "Economy" 8 "Violence" 9 "Governance" 10 "Gender" 11 "Other", modify
		lab value outcome outcomes
	
		twoway (rspike min90 max90 outcome, hor lc(black) lw(thin) ) ///
			(scatter outcome estimate , msize(medsmall) ms(O) mc(black)) ///
			, ///
			legend(off) ///
			scheme(s2mono) graphregion(fcolor(white)) ///
			yscale(rev) ///
			xsc(r(-0.15 0.15)) ///
			ylabel(#11, angle(horizontal) valuelabel labs(3.2) nogrid) ///
			xlabel(#6, labs(3.2)) ///
			xline(0, lpattern(shortdash)) ///
			xtitle("Marginal Effect of Policy Domain Prioritization" , size(3.2)) ytitle("")
		graph save "cz_polpri_margin", replace
		graph export "cz_polpri_margin.pdf", replace
	restore

	*graph predicted probabilities (top panel in Figure 7) 
	postfile pp str15 var str15 female pp pp_se pooled str15 sample str15 controls using "cz_pp.dta", replace
		
	foreach y in $outcomes {
		est restore `y'
		qui: margins, at(female=(0 1)) atmeans 
		matrix A=r(table)
		post pp ("`y'") ("Male") (A[1,1]) (A[2,1]) (1) ("Pooled") ("Min")
		post pp ("`y'") ("Female") (A[1,2]) (A[2,2]) (1) ("Pooled") ("Min")
		}
		
	postclose pp

	preserve
		use "cz_pp.dta", clear
		gen min90=pp-(pp_se*1.645)
		gen max90=pp+(pp_se*1.645)
		gen id=_n
		gen axis=id*-1
		sort axis
		sencode var, gen(outcome)

		lab define outcomes 11 "Infrastructure" 10 "Water" 9 "Health" 8 "Education" 7 "Poverty" 6 "Agriculture" 5 "Economy" 4 "Violence" 3 "Governance" 2 "Gender" 1 "Other", modify
		
		lab value outcome outcomes
		
		replace outcome=outcome + 0.25 if female=="Male"

		twoway (rspike min90 max90 outcome if female=="Male" & sample=="Pooled" & controls=="Min", hor lc(black) lw(thin)) ///
			(scatter outcome pp if female=="Male" & sample=="Pooled" & controls=="Min", msize(medsmall) mc(black) msymbol(Oh)) ///
			(rspike min90 max90 outcome if female=="Female" & sample=="Pooled" & controls=="Min", hor lc(black) lw(thin)) ///
			(scatter outcome pp if female=="Female" & sample=="Pooled" & controls=="Min", msize(medsmall) mc(black) msymbol(T)) ///
			, ///
			legend(order(2 "Male" 4 "Female") size (vmed) row(2) region(lw(none) fc(none)) ring(0) pos(5)) ///
			scheme(s2mono) graphregion(fcolor(white)) ///
			ylabel(#11, angle(horizontal) valuelabel labs(3.2) nogrid) ///
			xlabel(#6, labs(3.2)) ///
			xtitle("Predicted Probability of Policy Domain Prioritization", size(3.2)) ytitle("")
		graph save "cz_polpri_pp", replace
		graph export "cz_polpri_pp.pdf", replace
	restore
	
